<template>
  <div class="scrollBox">
    <pdf v-for="item in numPages" :key="item" :src="pdfSrc" :page="item" ref="pdf"></pdf>
  </div>
</template>

<script>
import pdf from 'vue-pdf'
export default {
  components: {
    pdf
  },
  name: "Booking",
  data(){
    return {
      pdfSrc: this.$store.state.ossBaseUrl + this.$route.query.url,
      numPages: '', // pdf 总页数
    }
  },
  methods: {
    getNumPages() {
      let loadingTask = pdf.createLoadingTask(this.pdfSrc)
      loadingTask.promise.then(pdf => {
        this.numPages = pdf.numPages
      }).catch(err => {
        console.error('pdf 加载失败', err);
      })
    }
  }
  ,
  created() {
    this.getNumPages();
  }
}
</script>

<style scoped>

</style>
